package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.DateUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Etcb4;
import com.ruoyi.system.service.IEtcb4Service;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * Controller
 * 
 * @author ruoyi
 * @date 2025-01-03
 */
@RestController
@RequestMapping("/system/etcb4")
public class Etcb4Controller extends BaseController
{
    @Autowired
    private IEtcb4Service etcb4Service;

    /**
     * 查询列表
     */
    @PreAuthorize("@ss.hasPermi('system:etcb4:list')")
    @GetMapping("/list")
    public TableDataInfo list(Etcb4 etcb4)
    {
        startPage();
        List<Etcb4> list = etcb4Service.selectEtcb4List(etcb4);
        return getDataTable(list);
    }

    /**
     * 导出列表
     */
    @PreAuthorize("@ss.hasPermi('system:etcb4:export')")
    @Log(title = "", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Etcb4 etcb4)
    {
        List<Etcb4> list = etcb4Service.selectEtcb4List(etcb4);
        ExcelUtil<Etcb4> util = new ExcelUtil<Etcb4>(Etcb4.class);
        util.exportExcel(response, list, "数据");
    }

    /**
     * 获取详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:etcb4:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(etcb4Service.selectEtcb4ById(id));
    }

    /**
     * 新增
     */
    @PreAuthorize("@ss.hasPermi('system:etcb4:add')")
    @Log(title = "", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Etcb4 etcb4)
    {
        etcb4.setMsgId(DateUtils.dateTimeNow(DateUtils.YYYYMMDDHHMMSSSSS));
        return toAjax(etcb4Service.insertEtcb4(etcb4));
    }

    /**
     * 修改
     */
    @PreAuthorize("@ss.hasPermi('system:etcb4:edit')")
    @Log(title = "", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Etcb4 etcb4)
    {
        return toAjax(etcb4Service.updateEtcb4(etcb4));
    }

    /**
     * 删除
     */
    @PreAuthorize("@ss.hasPermi('system:etcb4:remove')")
    @Log(title = "", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(etcb4Service.deleteEtcb4ByIds(ids));
    }
}
